#e
#Title[╄u-273x̐Îv]
#Text[]
#ScriptVersion[2]

script_enemy_main {
    let imgBoss =  GetCurrentScriptDirectory~".\chirno.png";

    @Initialize {
        LoadGraphic(imgBoss);
        SetTexture(imgBoss);
        SetGraphicRect(0, 0, 63, 63);
        SetLife(1);
        CutIn(YOUMU,"╄u-273x̐Îv", "", 0, 0, 0, 0);
        SetTimer(88);
        SetScore(1000000);
        SetDamageRate(0,0);
        SetDurableSpellCard();
        Tshot;
        Tplayer;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 24);
        SetCollisionB(GetX, GetY, 24);

        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(imgBoss);
    }
    sub standBy {

        SetMovePosition02(228, 136, 30);
        setGraphicMove;
        loop(30){yield;}
        setGraphicStop;
        loop(70){yield;}
    }

    sub setGraphicStop  { SetGraphicRect(  0,   0, 128, 128); }
    sub setGraphicLeft  { SetGraphicRect(256,   0, 384, 128); }
    sub setGraphicRight { SetGraphicRect(256, 256, 384, 384); }

    sub setGraphicMove {
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } else {
            setGraphicRight;
        }
    }
    task Tshot{
        yield;
           standBy;
       loop(100){yield;}
       let id = 1;
        loop{
           let x = rand(0,448);
           let y = rand(0,480);
           let z = rand(0,3);
           CreateShotA(id,x,y,0);
           SetShotDataA(id,0,0,0,0,0,0,AQUA05);
           SetShotDataA(id,300,0,0,0,0,0,AQUA03);
           if(z >2){
           SetShotKillTime(id,2000);
           }
	   if(x > GetPlayerX+10 || x < GetPlayerX-10  || y > GetPlayerY+10 || y < GetPlayerY-10 )
           {
           FireShot(id);
           }
           id ++;
           loop(20){yield;}
         }     
      }
    task Tplayer{
        yield;
       loop(500){yield;}
        loop{
         loop(4){  
           CreateShot01(rand(GetPlayerX-35,GetPlayerX+35),rand(GetPlayerY-35,GetPlayerY+35),0,0,BLUE03,100);
               }
           loop(400){yield;}
         }     
      }
    
    function nway(dir, way, span, color) {

        let radius = 32;


        let angle  = dir - (way - 1) / 2 * span;

        loop(way) {

            CreateShot01(GetX, GetY, 1, angle, color, 0);
            angle += span;
        }
    }

}